package com.java.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public interface PlayerMapper {
    @Select("select * from competitor_groups")
    List<Map<String,Object>> selectAllPlayer();

    /**
     * 参赛选手注册，插入数据
     */
    @Insert("INSERT INTO competitor_groups SET teamName=#{teamName},competitorName_1=#{competitorName_1},class_1=#{class_1},competitorName_2=#{competitorName_2},class_2=#{class_2},competitorName_3=#{competitorName_3},class_3=#{class_3},captain_phone=#{captain_phone}")
    int insertPlayer(Map<String,Object> map);

    /**
     * 参赛选手查询本队信息，以队长手机号查询
     */
    @Select("SELECT * from competitor_groups WHERE captain_phone=#{phone} LIMIT 1;")
    Map<String,Object> selectOnePlayer(Map<String,Object> map);

    @Update("UPDATE competitor_groups SET teamName=#{teamName},competitorName_1=#{competitorName_1},class_1=#{class_1},competitorName_2=#{competitorName_2},class_2=#{class_2},competitorName_3=#{competitorName_3},class_3=#{class_3},captain_phone=#{captain_phone} where id=#{id}")
    int updateTeamInfo(Map<String,Object> map);
}